import json
import re

def extract_links_from_json_file(file_path):
    with open(file_path, 'r', encoding='utf-8') as file:
        json_data = json.load(file)

        # 正则表达式匹配https开头的链接
        pattern = r'https://\S+'
        links = []

        # 遍历JSON数据，提取链接
        def extract_links(data):
            if isinstance(data, dict):
                for value in data.values():
                    extract_links(value)
            elif isinstance(data, list):
                for item in data:
                    extract_links(item)
            elif isinstance(data, str):
                matches = re.findall(pattern, data)
                links.extend(matches)

        extract_links(json_data)

    return links

# 调用函数进行测试
file_path = 'json/latest.json'  # 替换为实际的JSON文件路径
links = extract_links_from_json_file(file_path)
for i in links:
    print(i)
